package ar.edu.unq.wannaplay.dtos;

import ar.edu.unq.wannaplay.employee.Experience;
import ar.edu.unq.wannaplay.employee.Skill;

public class SkillDTO extends DTO<Skill> {

    private static final long serialVersionUID = 1L;

    private String knowledge;

    private Experience experience;

    private int id;

    public SkillDTO() {
        super();
        // Empty constructor, entirely made for bindingConstruction on
        // presentationModel
    }

    public SkillDTO(final Experience exp, final String knowd) {
        super();
        knowledge = knowd;
        experience = exp;
    }

    public SkillDTO(final Skill skill) {
        super();
        knowledge = skill.getKnowledge();
        experience = skill.getExperience();
    }

    public String getKnowledge() {
        return knowledge;
    }

    public void setKnowledge(final String knowledge) {
        this.knowledge = knowledge;
    }

    public Experience getExperience() {
        return experience;
    }

    public void setExperience(final Experience experience) {
        this.experience = experience;
    }

    public int getId() {
        return id;
    }

    @Override
    public Skill fromDto() {
        Skill fromDto = new Skill(this.getKnowledge(), this.getExperience());
        fromDto.setId(this.getId());
        return fromDto;
    }

    public void setId(final int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return this.getKnowledge() + " " + this.getExperience().toString();
    }

    @Override
    public int hashCode() {
        int prime = 31;
        int result = 1;
        result = prime * result + (experience == null ? 0 : experience.hashCode());
        result = prime * result + id;
        result = prime * result + (knowledge == null ? 0 : knowledge.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        SkillDTO other = (SkillDTO) obj;
        if (experience != other.experience) {
            return false;
        }
        if (id != other.id) {
            return false;
        }
        if (knowledge == null) {
            if (other.knowledge != null) {
                return false;
            }
        } else if (!knowledge.equals(other.knowledge)) {
            return false;
        }
        return true;
    }

}
